﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="SysDictionary.aspx.cs" Inherits="ExaminationSys.SystemManage.SysDictionary" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<!DOCTYPE html>

<html>
<head id="Head1" runat="server">
    <title>Remote mode - Ext.NET Examples</title>
    <link href="/resources/css/examples.css" rel="stylesheet" type="text/css" />
    
    <style type="text/css">
        .bold-text{
            font-weight:bold;
            padding-left: 32px;
            margin-bottom:2px;
            font-size:110%;
        }
    </style>
    
    <script type="text/javascript">
        var showMenu = function (view, node, item, index, e) {
            var menu = App.TreeContextMenu;

            this.menuNode = node;
            menu.nodeName = node.get("text");
            view.getSelectionModel().select(node);

            menu.showAt([e.getXY()[0], e.getXY()[1] + 10]);
            e.stopEvent();
        };
    </script>
</head>
<body>
    <form id="Form1" runat="server">
        <ext:ResourceManager runat="server" />
        
        <h1>系统字典配置界面</h1>
 
         <ext:Menu ID="TreeContextMenu" runat="server">
            <Items>
                <ext:Label ID="NodeName" runat="server" Cls="bold-text" />
                <ext:MenuSeparator />
                <ext:MenuItem runat="server" Text="编辑" Icon="Pencil">
                    <Listeners>
                        <Click Handler="#{TreePanel1}.editingPlugin.startEdit(#{TreePanel1}.menuNode, 0);" />
                    </Listeners>
                </ext:MenuItem>

                <ext:MenuItem runat="server" Text="重命名" Icon="Pencil">
                    <Listeners>
                        <Click Handler="#{TreePanel1}.editNode(#{TreePanel1}.menuNode, 'text', 'TEST');" />
                    </Listeners>
                </ext:MenuItem>
                
                <ext:MenuItem runat="server" Text="删除" Icon="Delete">
                    <Listeners>
                        <Click Handler="#{TreePanel1}.removeNode(#{TreePanel1}.menuNode);" />
                    </Listeners>
                </ext:MenuItem>
                
                <ext:MenuItem runat="server" Text="新增子节点" Icon="Add">
                    <Listeners>
                        <Click Handler="#{TreePanel1}.appendChild(#{TreePanel1}.menuNode, 'New');" />
                    </Listeners>
                </ext:MenuItem>
                
                <ext:MenuItem runat="server" Text="在前面插入新节点" Icon="ArrowRight">
                    <Listeners>
                        <Click Handler="#{TreePanel1}.insertBefore(#{TreePanel1}.menuNode, 'New');" />
                    </Listeners>
                </ext:MenuItem>
            </Items>
            <Listeners>
                <Show Handler="#{NodeName}.setText(this.nodeName);" />
            </Listeners>
        </ext:Menu>
        
        
        <ext:TreePanel 
            ID="TreePanel1"
            runat="server" 
            Height="300" 
            Width="250"
            UseArrows="true"
            AutoScroll="true"
            Animate="true"
            Mode="Remote"
            RootVisible="false"
            RemoteJson="true"
            ContainerScroll="true"        
            RemoteEditUrl="../asmx/SysDictionary.asmx/RemoteEdit"
            RemoteRemoveUrl="../asmx/SysDictionary.asmx/RemoteRemove"
            RemoteAppendUrl="../asmx/SysDictionary.asmx/RemoteAppend"
            RemoteInsertUrl="../asmx/SysDictionary.asmx/RemoteInsert"
            RemoteMoveUrl="../asmx/SysDictionary.asmx/RemoteMove">                        
            <Editor>
                <ext:TextField runat="server"/>
            </Editor>
            
            <Store>
                <ext:TreeStore runat="server">
                    <Proxy>
                        <ext:AjaxProxy Url="../asmx/SysDictionary.asmx/GetNodes" Json="true">                            
                            <ActionMethods Read="POST" />
                            <Reader>
                                <ext:JsonReader Root="d" />
                            </Reader>
                        </ext:AjaxProxy>
                    </Proxy>   
                    <Root>
                        <ext:Node NodeID="Root" />
                    </Root>                 
                </ext:TreeStore>
            </Store>

            <DirectEventConfig Method="POST" />
            
            <Listeners>
                <ItemContextMenu Fn="showMenu" StopEvent="true" />
                <RemoteActionRefusal Handler="Ext.Msg.alert('Action refusal', e.message);" />
            </Listeners>

            <View>
                <ext:TreeView runat="server">
                    <Plugins>
                        <ext:TreeViewDragDrop runat="server" AllowLeafDrop="true" />
                    </Plugins>
                </ext:TreeView>
            </View>

            <Plugins>                
                <ext:CellEditing runat="server" />
            </Plugins>
        </ext:TreePanel>
    </form>
</body>
</html>